/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

/**
 * <p>Project: jse2303 - T7</p>
 * <p>Powered by webrx On 2023-07-26 17:53:10</p>
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class T8 {
    int count = 0;

    Vector<Integer> list = new Vector<>();

    public static void main(String[] args) throws Exception {
        var t8 = new T8();
        List<Thread> threads = new ArrayList<Thread>();
        for (int i = 0; i < 10; i++) {
            threads.add(new Thread(t8::m, "thread-" + i));
        }
        threads.forEach((o) -> o.start());
        threads.forEach((o) -> {
            try {
                o.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        System.out.println(t8.list.size());
    }

    void m() {
        for (int i = 0; i < 10000; i++) {
            list.add(1);
        }
        String t = Thread.currentThread().getName();
        System.out.println(t);

    }
}
